using System;
using NUnit.Framework;
using DotNetXmlSwfChart;

namespace DotNetXmlSwfChart.UnitTest
{
    [TestFixture]
    public class DrawCircleFixture
    {
        [Test]
        public void DrawCircleBackgroundLayerDissolveTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.dissolve);
        }

        [Test]
        public void DrawCircleForegroundLayerDissolveTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.dissolve);
        }

        [Test]
        public void DrawCircleBackgroundLayerDropTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.drop);
        }

        [Test]
        public void DrawCircleForegroundLayerDropTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.drop);
        }

        [Test]
        public void DrawCircleBackgroundLayerSpinTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.spin);
        }

        [Test]
        public void DrawCircleForegroundLayerSpinTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.spin);
        }

        [Test]
        public void DrawCircleBackgroundLayerScaleTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.scale);
        }

        [Test]
        public void DrawCircleForegroundLayerScaleTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.scale);
        }

        [Test]
        public void DrawCircleBackgroundLayerZoomTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.zoom);
        }

        [Test]
        public void DrawCircleForegroundLayerZoomTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.zoom);
        }

        [Test]
        public void DrawCircleBackgroundLayerBlinkTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.blink);
        }

        [Test]
        public void DrawCircleForegroundLayerBlinkTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.blink);
        }

        [Test]
        public void DrawCircleBackgroundLayerSlideRightTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.slide_right);
        }

        [Test]
        public void DrawCircleForegroundLayerSlideRightTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.slide_right);
        }

        [Test]
        public void DrawCircleBackgroundLayerSlideLeftTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.slide_left);
        }

        [Test]
        public void DrawCircleForegroundLayerSlideLeftTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.slide_left);
        }

        [Test]
        public void DrawCircleBackgroundLayerSlideUpTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.slide_up);
        }

        [Test]
        public void DrawCircleForegroundLayerSlideUpTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.slide_up);
        }

        [Test]
        public void DrawCircleBackgroundLayerSlideDownTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.slide_down);
        }

        [Test]
        public void DrawCircleForegroundLayerSlideDownTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.slide_down);
        }

        [Test]
        public void DrawCircleBackgroundLayerNoTransition()
        {
            CircleTest(DrawLayer.background, TransitionType.none);
        }

        [Test]
        public void DrawCircleForegroundLayerNoTransition()
        {
            CircleTest(DrawLayer.foreground, TransitionType.none);
        }

        private void CircleTest(DrawLayer layer, TransitionType type)
        {
            string testXml =
                "<circle layer='{0}' " +
                        "transition='{1}' " +
                        "delay='1.2' " +
                        "duration='2.2' " +
                        "x='20' " +
                        "y='40' " +
                        "radius='8' " +
                        "fill_color='ffffff' " +
                        "fill_alpha='2' " +
                        "line_color='f0f0f0' " +
                        "line_alpha='1' " +
                        "line_thickness='2' " +
                        "/>";
            DrawCircle circle = new DrawCircle();
            circle.Layer = layer;
            circle.Transition = type;
            circle.Delay = 1.2;
            circle.Duration = 2.2;
            circle.X = 20;
            circle.Y = 40;
            circle.Radius = 8;
            circle.FillColor = "ffffff";
            circle.FillAlpha = 2;
            circle.LineColor = "f0f0f0";
            circle.LineAlpha = 1;
            circle.LineThickness = 2;
            Assert.AreEqual(
                string.Format(testXml, layer.ToString(), type.ToString()),
                circle.ToSourceXML());
        }
    }
}
